package com.lagou.rpc.provider;

import com.lagou.rpc.provider.server.RpcServer;
import com.lagou.rpc.zookeeper.config.ConfigKeeper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ServerBootstrapApplication  implements CommandLineRunner {

    @Autowired
    private RpcServer rpcServer;



    public static void main(String[] args) {
        //zookeeper初始化配置
        ConfigKeeper configKeeper = ConfigKeeper.getInstance();
        configKeeper.setConnectString("192.168.150.132:2181");
        configKeeper.setProviderSide(true);
        configKeeper.setPort(7778);

        SpringApplication.run(ServerBootstrapApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        new Thread(()->{
            rpcServer.startServer("127.0.0.1",ConfigKeeper.getInstance().getPort());
        }).start();
    }
}
